home *** CD-ROM | disk | FTP | other *** search
/ PC Play 129 / pc play 129.iso / Demo / man2 / man2.exe / data / scripts / helicopter_scripts.lua < prev    next >
Encoding:
Text File  |  2009-04-27  |  6.4 KB  |  173 lines

  1.  
  2. function units_helicopter_setup()
  3.     units_setup(3,false,ENET_EFFECT_PS_SETUPSMOKE_MEDIUM,ENET_EFFECT_GEOMETRY_HELICOPTERSHADOW,true)
  4.     local unit = uniGetExecutor()
  5.     unit:getBone(ENBT_FAN,0):addRotationEffect(ENET_EFFECT_ROTATE_WHEEL,-MATH_PI * 2)
  6.     unit:getBone(ENBT_FAN,1):addRotationEffect(ENET_EFFECT_ROTATE_WHEEL,-MATH_PI * 2)
  7.     unit:getBone(ENBT_FAN,2):addRotationEffect(ENET_EFFECT_ROTATE_RADAR,MATH_PI * 2)
  8.     unit:getBone(ENBT_FAN,3):addRotationEffect(ENET_EFFECT_ROTATE_RADAR,-MATH_PI / 4)
  9.     unit:getBone(ENBT_FAN,3):addSimpleEffect(ENET_EFFECT_BINDEDSPRITE_HELICOPTERPROPELLER)
  10.     unit:addSimpleEffect(ENET_EFFECTEMITTER_HELICOPTERWATERWAVES)
  11.     unit:addSimpleEffect(ENET_EFFECT_HELICOPTER_WATERWAVES2)
  12. end
  13.  
  14. function units_helicopter_resetup()
  15.     units_setup(3,false,nil,ENET_EFFECT_GEOMETRY_HELICOPTERSHADOW,true)
  16.     local unit = uniGetExecutor()
  17.     unit:getBone(ENBT_FAN,0):addRotationEffect(ENET_EFFECT_ROTATE_WHEEL,-MATH_PI * 2)
  18.     unit:getBone(ENBT_FAN,1):addRotationEffect(ENET_EFFECT_ROTATE_WHEEL,-MATH_PI * 2)
  19.     unit:getBone(ENBT_FAN,2):addRotationEffect(ENET_EFFECT_ROTATE_RADAR,MATH_PI * 2)
  20.     unit:getBone(ENBT_FAN,3):addRotationEffect(ENET_EFFECT_ROTATE_RADAR,-MATH_PI / 4)
  21.     unit:getBone(ENBT_FAN,3):addSimpleEffect(ENET_EFFECT_BINDEDSPRITE_HELICOPTERPROPELLER)
  22.     unit:addSimpleEffect(ENET_EFFECTEMITTER_HELICOPTERWATERWAVES)
  23.     unit:addSimpleEffect(ENET_EFFECT_HELICOPTER_WATERWAVES2)
  24. end
  25.  
  26. function units_helicopter_select()
  27.     units_select(20,2)
  28. end
  29.  
  30. function units_helicopter_unselect()
  31.     units_unselect()
  32. end
  33.  
  34. function units_helicopter_selectenemy()
  35.     uniGetExecutor():addSimpleEffect(ENET_EFFECT_SELECTEDGEOMETRY_ENEMY)
  36. end
  37.  
  38. function units_helicopter_damaged()
  39.     uniGetExecutor():applyDamage(uniGetLife())
  40. end
  41.  
  42. function units_helicopter_highlight()
  43.     uniGetExecutor():addEffectWithRadius(ENET_EFFECT_GEOMETRY_HIGHLIGHT,15)
  44. end
  45.  
  46. function units_helicopter_explode()
  47.     uniGetExecutor():getBone(ENBT_FAN,3):findEffect(ENET_EFFECT_BINDEDSPRITE_HELICOPTERPROPELLER):destroy()
  48.     units_explode_fire()
  49. end
  50.  
  51. function units_helicopter_fire()
  52.     uniSetLife(uniGetLife() / 2.0)
  53.     local unit = uniGetExecutor()
  54.  
  55.     local wPos = unit:getWorldPosition()
  56.     wPos.y = wPos.y + 30
  57.     unit:play3DSound("chopper fade.wav",0)
  58.     local up = unit:linearFly(wPos,50)
  59.     local up_holder = enHolder:new(up)
  60.     waitDeath(unit:addRotationEffect(ENET_EFFECT_ROTATE_UNITTOTARGET,MATH_PI / 1.5,uniGetTarget()))
  61.     waitDeath(up)
  62.     waitDeath(unit:getBone(ENBT_TARGET):addRotationEffect(ENET_EFFECT_ROTATE_GUNTOTARGET,MATH_PI / 3.0,uniGetTarget()))
  63.     
  64.     local firespots = {}
  65.     firespots[0] = unit:getBone(ENBT_FIRE1,0)
  66.     firespots[1] = unit:getBone(ENBT_FIRE1,1)
  67.     local recoils = {}
  68.     recoils[0] = unit:getBone(ENBT_RECOIL,0)
  69.     recoils[1] = unit:getBone(ENBT_RECOIL,1)
  70.  
  71.     firespots[0]:addSimpleEffect(ENET_EFFECT_HELICOPTERSHOT_FLY):executeCommand(ENC_FIRE1)
  72.     unit:play3DSound("chopper fire2.wav",0)
  73.     local shot2 = firespots[0]:addBulletEffect(ENET_EFFECT_PS_HELICOPTERSHOT)
  74.     recoils[1]:gunRecoil(0,0.3,10.0)
  75.     pause(0.3)
  76.     firespots[1]:addSimpleEffect(ENET_EFFECT_HELICOPTERSHOT_FLY):executeCommand(ENC_FIRE1)
  77.     unit:play3DSound("chopper fire2.wav",0)
  78.     local shot2_2 = firespots[1]:addBulletEffect(ENET_EFFECT_PS_HELICOPTERSHOT)
  79.     recoils[0]:gunRecoil(0,0.3,10.0)
  80.  
  81.     shot2:suspendedDestroy(0.5)
  82.     shot2_2:suspendedDestroy(0.5)
  83.  
  84.     pause(0.5)
  85.     unit:getBone(ENBT_TARGET):addRotationEffect(ENET_EFFECT_ROTATE_GUNDEFAULT,MATH_PI / 3.0)
  86.     wPos.y = wPos.y - 30
  87.     waitDeath(unit:linearFly(wPos,50))
  88.  
  89.     unit:addFireArrow()
  90. end
  91.  
  92. function units_helicopter_move()
  93.     local unit = uniGetExecutor()
  94.     --local sound = unit:play3DSound("chopper.wav",1)
  95.     waitDeath(unit:helicopterFly(uniGetPosition()))
  96. --[[
  97.     local mover = unit:helicopterFly(uniGetPosition())
  98.     local mover_holder = enHolder:new(mover)
  99.     while mover:isAlive() do
  100.         if getHeightType(unit:getWorldPosition()) == ENBHT_WATERHIT then
  101.             local wave = unit:addSimpleEffect(ENET_EFFECT_BINDEDSPRITE_WATERSHOCKWAVE)
  102.             wave:setTransformOwner()
  103.         end
  104.         pause(0.1)
  105.     end
  106. ]]--
  107.     --sound:destroy()
  108. end
  109.  
  110. registerCommand(ENSCRIPTSET_HELICOPTER,ENC_MOVE,"units_helicopter_move")
  111. registerCommand(ENSCRIPTSET_HELICOPTER,ENC_FIRE1,"units_helicopter_fire")
  112. registerCommand(ENSCRIPTSET_HELICOPTER,ENC_FIRE2,"units_helicopter_fire")
  113. registerCommand(ENSCRIPTSET_HELICOPTER,ENC_SELECT,"units_helicopter_select")
  114. registerCommand(ENSCRIPTSET_HELICOPTER,ENC_SELECTENEMY,"units_helicopter_selectenemy")
  115. registerCommand(ENSCRIPTSET_HELICOPTER,ENC_UNSELECT,"units_helicopter_unselect")
  116. registerCommand(ENSCRIPTSET_HELICOPTER,ENC_SETUP,"units_helicopter_setup")
  117. registerCommand(ENSCRIPTSET_HELICOPTER,ENC_RESETUP,"units_helicopter_resetup")
  118. registerCommand(ENSCRIPTSET_HELICOPTER,ENC_DAMAGED,"units_helicopter_damaged")
  119. registerCommand(ENSCRIPTSET_HELICOPTER,ENC_EXPLODE,"units_helicopter_explode")
  120. registerCommand(ENSCRIPTSET_HELICOPTER,ENC_HIGHLIGHT,"units_helicopter_highlight")
  121.  
  122. -- make description of unit
  123. desc = getEffectDescriptionP(ENET_UNIT_HELICOPTER)
  124. desc.ClassID = ENCLASS_MESHINSTANCE
  125. desc.EffectClassType = ENECT_GEOMETRY
  126. desc.FileName = "helicopter.rmd"
  127. desc.ScriptSet = ENSCRIPTSET_HELICOPTER
  128. desc.MoveType = ENMOVE_FLYCONSTANTHEIGHT
  129. --desc.MoveType = ENMOVE_GROUND
  130. desc.RenderType = ENRENDERTYPE_GEOMETRY
  131. desc.Material = ENMAT_RIGIDSKINNEDMESH
  132. desc.MaterialColors = units_materialcolors_human
  133.  
  134. -- shadow
  135. desc = getEffectDescriptionP(ENET_EFFECT_GEOMETRY_HELICOPTERSHADOW)
  136. desc.ClassID = ENCLASS_MESHINSTANCE
  137. desc.EffectClassType = ENECT_GEOMETRY
  138. desc.FileName = "helicopter_shadow.rmd"
  139. desc.RenderType = ENRENDERTYPE_SHADOW
  140. desc.Material = ENMAT_SHADOW
  141. desc.MaterialColors = units_materialcolors_shadow
  142.  
  143. -- register new unit to logic
  144. unitDesc = logic_getUnitDescP(27)
  145. unitDesc.group = 2
  146. unitDesc.order = 3
  147. unitDesc.unit_res_id = ENET_UNIT_HELICOPTER
  148. unitDesc.unit_icon_id = "Helicopter_h_small_normal.dds"
  149. unitDesc.active_id = "Helicopter_h_small_active.dds"
  150. unitDesc.pressed_id = "Helicopter_h_small_pressed.dds"
  151. unitDesc.big_icon_id = "Helicopter_h_big_normal.dds"
  152. unitDesc.small_icon_id = "Attackcopter_u_stats.dds"
  153. unitDesc.HP = 3
  154. unitDesc.MP = 40
  155. unitDesc.WR = 2
  156. unitDesc.min_WR = 0
  157. unitDesc.WD = 2
  158. unitDesc.WR2 = 0
  159. unitDesc.min_WR2 = 0
  160. unitDesc.WD2 = 0
  161. unitDesc.ability = 5
  162. unitDesc.transport = 0
  163. unitDesc.value = 3
  164. unitDesc.race = 0
  165. unitDesc.fire_pause = 0.6
  166. unitDesc.move_pause = 0.5
  167. unitDesc.unit_info_scale = 0.07
  168. unitDesc.scn_name = "ATTCHOPPER"
  169.  
  170.  
  171. -- effects related to unit
  172. executeScript("scripts\\helicopter_effects_scripts\\helicopter_waterwaves.lua")
  173.